import { getBannerAjax, getHotRecommends, getNewAlbums,getDjHot } from "@/http/modules/hall";
const { createSlice, createAsyncThunk } = require("@reduxjs/toolkit");

export const getBannerInfo = createAsyncThunk("banner",async ()=>{
    const res = await getBannerAjax();
    return res.banners
})

export const getHotRecommendsInfo = createAsyncThunk("recommends",async ()=>{
    const res = await getHotRecommends();
    return res.result;
})

export const getNewAlbumsInfo = createAsyncThunk("newAlbums",async ()=>{
    const res = await getNewAlbums();
    return res.albums;
})

export const getDjHotInfo = createAsyncThunk("djhot",async ()=>{
    const res = await getDjHot();
    return res.djRadios
})

const hallSlice = createSlice({
    name:"hall",
    initialState:{
        banners:[],
        hotRecommends:[],
        newAlbums:[],
        djhot:[]
    },
    extraReducers:{
        [getBannerInfo.fulfilled](state,{payload}){
            state.banners = payload;
        },
        [getHotRecommendsInfo.fulfilled](state,{payload}){
            state.hotRecommends = payload;
        },
        [getNewAlbumsInfo.fulfilled](state,{payload}){
            state.newAlbums = payload;
        },
        [getDjHotInfo.fulfilled](state,{payload}){
            state.djhot = payload
        }
    }
})

export default hallSlice.reducer